using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ShivamEMR.Model.Domain.DoctorsDomain;
using ShivamEMR.Model.DataInterfaces.DoctorDataInterf;
using ShivamEMR.Model;
//using ShivamEMR.Web.Areas.Doctor.Models;

namespace ShivamEMR.Web.Areas.Doctor.Controllers
{   
    public class SpecialtiesController : Controller
    {
        private readonly ISpecialtiesRepository specialtyRepository;

		// If you are using Dependency Injection, you can delete the following constructor
        public SpecialtiesController()  
        {
            specialtyRepository = Registry.RepositoryFactory.GetSpecialtiesRepository();
        }

        public SpecialtiesController(ISpecialtiesRepository specialtyRepository)
        {
			this.specialtyRepository = specialtyRepository;
        }

        //
        // GET: /Specialties/

        public ViewResult Index()
        {
            //return View(specialtyRepository.AllIncluding(specialty => specialty.Doctors));
            return View(specialtyRepository.All);
        }

        //
        // GET: /Specialties/Details/5

        public ViewResult Details(int id)
        {
            return View(specialtyRepository.Find(id));
        }

        //
        // GET: /Specialties/Create

        public ActionResult Create()
        {
            return View();
        } 

        //
        // POST: /Specialties/Create

        [HttpPost]
        public ActionResult Create(Specialty specialty)
        {
            if (ModelState.IsValid) {
                specialtyRepository.InsertOrUpdate(specialty);
                specialtyRepository.Save();
                return RedirectToAction("Index");
            } else {
				return View();
			}
        }
        
        //
        // GET: /Specialties/Edit/5
 
        public ActionResult Edit(int id)
        {
             return View(specialtyRepository.Find(id));
        }

        //
        // POST: /Specialties/Edit/5

        [HttpPost]
        public ActionResult Edit(Specialty specialty)
        {
            if (ModelState.IsValid) {
                specialtyRepository.InsertOrUpdate(specialty);
                specialtyRepository.Save();
                return RedirectToAction("Index");
            } else {
				return View();
			}
        }

        //
        // GET: /Specialties/Delete/5
 
        public ActionResult Delete(int id)
        {
            return View(specialtyRepository.Find(id));
        }

        //
        // POST: /Specialties/Delete/5

        [HttpPost, ActionName("Delete")]
        public ActionResult DeleteConfirmed(int id)
        {
            var sp = specialtyRepository.Find(id);
            specialtyRepository.Delete(sp);
            specialtyRepository.Save();

            return RedirectToAction("Index");
        }
    }
}

